/**
 * ReportGear(2011)
 */
package com.reportgear.designer.pane.headerfooter;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.SwingUtilities;

import com.reportgear.core.swing.pane.base.JBasePane;
import com.reportgear.report.model.headerfooter.ReportHF;

/**
 * 面板-页眉页脚
 * 
 * @version 1.0 2011-4-22
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class HeaderFooterPane extends JBasePane {
	/**
	 * UID
	 */
	private static final long serialVersionUID = -540795496103525671L;
	private HeaderFooterEditPane headerFooterEditPane;
	// 是否编辑页眉
	private boolean editHeader = true;

	public HeaderFooterPane() {
		this.initComponents();
	}

	private void initComponents() {
		this.setLayout(new BorderLayout());

		this.headerFooterEditPane = new HeaderFooterEditPane();
		this.add(this.headerFooterEditPane, BorderLayout.CENTER);
	}

	public void populate(ReportHF reportHF) {
		this.headerFooterEditPane.populate(reportHF);
	}

	public ReportHF update() {
		return this.headerFooterEditPane.update();
	}

	public int showInDialog(Component owner) {
		return this.showDialog(SwingUtilities.getWindowAncestor(owner), this.getTitle(), 560, 410);
	}

	private String getTitle() {
		if (this.editHeader) {
			return "编辑页眉";
		} else {
			return "编辑页脚";
		}
	}

	/**
	 * 是指是否编辑页眉
	 * 
	 * @param editHeader
	 *            编辑页眉
	 */
	public void setEditHeader(boolean editHeader) {
		this.editHeader = editHeader;
	}

	public boolean isEditHeader() {
		return editHeader;
	}
}
